package xm.erzhan.conf.ResourcesConf;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

public class Oilfield {
    private static Oilfield oilfieldIns;

    public class OilfieldItem {
        public int lv;
        public int costFood;
        public int costSteel;
        public int costOil;
        public int costSlime;
        public int product;
        public int costSec;

        public OilfieldItem(int lv, int costFood, int costSteel, int costOil, int costSlime, int product, int costSec) {
            this.lv = lv;
            this.costFood = costFood;
            this.costSteel = costSteel;
            this.costOil = costOil;
            this.costSlime = costSlime;
            this.product = product;
            this.costSec = costSec;

        }
    }

    public List<Oilfield.OilfieldItem> oilfieldItems = new ArrayList<Oilfield.OilfieldItem>();

    public Oilfield.OilfieldItem getConfByLv(int lv) {

        Oilfield.OilfieldItem oilfieldItem = null;

        Iterator<Oilfield.OilfieldItem> iterator = this.oilfieldItems.iterator();

        Oilfield.OilfieldItem item;
        while (iterator.hasNext()) {
            item = iterator.next();
            if (item.lv == lv) {
                oilfieldItem = item;
                break;
            }
        }

        return oilfieldItem;
    }

    public void initFarmlandItems() {

        this.oilfieldItems.add(new Oilfield.OilfieldItem(1, 100, 300, 350, 250, 500, 5));
        this.oilfieldItems.add(new Oilfield.OilfieldItem(2, 500, 700, 450, 750, 1000, 15));
        this.oilfieldItems.add(new Oilfield.OilfieldItem(3, 1300, 1500, 1450, 1550, 4500, 30));
        this.oilfieldItems.add(new Oilfield.OilfieldItem(4, 2500, 2700, 1650, 2750, 5000, 100));
        this.oilfieldItems.add(new Oilfield.OilfieldItem(5, 3500, 5700, 2600, 7750, 8000, 150));
        this.oilfieldItems.add(new Oilfield.OilfieldItem(6, 13500, 15700, 12650, 17750, 13500, 240));
        this.oilfieldItems.add(new Oilfield.OilfieldItem(7, 22100, 22200, 21150, 22250, 25000, 310));
        this.oilfieldItems.add(new Oilfield.OilfieldItem(8, 40100, 40200, 40150, 40250, 40500, 380));
        this.oilfieldItems.add(new Oilfield.OilfieldItem(9, 60100, 60200, 60150, 60250, 60500, 460));
    }

    public static Oilfield shared() {
        if (oilfieldIns == null) {
            oilfieldIns = new Oilfield();
            oilfieldIns.initFarmlandItems();
        }

        return oilfieldIns;
    }
}
